import axios from 'axios'
// 创建axios实例

document.cookie = 'x-customs-user==0nIxETMxETMxETMxETMtETMxETLxETMx0SMxETMtETMxETMxETZiojIlR2bDdXZpZnIsICmuWOktWekHmuI6ISZtFmTyV2c1JCLi42YuAXZucGauUWbhJnZiojIwlkclNXdiwiIulmanpnI6ICZJJXZzVnIsISMiojIzVHdhR3ciwiI1gTO1ITZ3MDM3QWNtkDM4QTLyIWOh1yMxYjYtQGOldTYlNjMiojIklWdHRnblJXYwJCLicTN6IDN6YTMggDMtgDMtUjMwIjI6ISZtlGV0NXZ0FGbiwiIiRzMyEmYwkDOmRjNtImMlRTL0MGOi1yMiRTYtgjNkZWNyQWYiojIklWdnJCLiYTMyIjI6ISZk92Qz12b0NXdjJCLigprlDZrlH5hpzFXd+L58u756yp5mWr5cx1sFW+t1a+t1aui4SOXcJbvnvLgmPbhlfbtmLiOigGdhBFbsFmIsIyctJ3bmJiOi0mYhJye'
const request = axios.create({
    baseURL: '/dev-api'+'/api/hg-digital-customs',// 所有的请求地址前缀部分
    timeout: 50000, // 请求超时时间(毫秒)
    withCredentials: true,// 异步请求携带cookie
    headers: {
    // 设置后端需要的传参类型
    // 'Cookie':cookie,
    // 'debug-user': 'jinziguan',
    'Content-Type': 'application/json',
    // 'token': 'x-auth-token',  //一开始就要token
    'X-Requested-With': 'XMLHttpRequest',
    },
})
 
// request拦截器
request.interceptors.request.use(
    config => {
        // 如果你要去localStor获取token,(如果你有)
        // let token = localStorage.getItem("x-auth-token");
        // if (token) {
                //添加请求头
                //config.headers["Authorization"]="Bearer "+ token
        // }
        return config
    },
    error => {
        // 对请求错误做些什么
        Promise.reject(error)
    }
)
 
// response 拦截器
request.interceptors.response.use(
    response => {
        // 对响应数据做点什么
        return response.data
    },
    error => {  
        // 对响应错误做点什么
        return Promise.reject(error)
    }
)
export default request